package com.itheima.health.utils.poi;

import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.usermodel.*;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;

@SuppressWarnings("ALL")
/**
 * @Description :
 * @author     :LD
 */
public class MyTest {
    public static void main(String[] args) throws Exception {
        //在内存中创建一个Excel文件
        XSSFWorkbook xssfWorkbook = new XSSFWorkbook();
        //创建工作表，指定工作表名称
        XSSFSheet sheet = xssfWorkbook.createSheet("统计分析");
        //创建行，0表示第一行
        XSSFRow row = sheet.createRow(0);
        //创建单元格，0表示第一个单元格
        row.createCell(0).setCellValue("会员数据统计");
        sheet.addMergedRegion(new CellRangeAddress(0,0,0,3));

        XSSFRow row1 = sheet.createRow(1);
        row1.createCell(0).setCellValue("今日新增会员数");
        row1.createCell(1).setCellValue("23");
        row1.createCell(2).setCellValue("总会员数");
        row1.createCell(3).setCellValue("230");

        XSSFRow row2 = sheet.createRow(2);
        row2.createCell(0).setCellValue("本周新增会员数");
        row2.createCell(1).setCellValue("22");
        row2.createCell(2).setCellValue("本月新增会员数");
        row2.createCell(3).setCellValue("234");

        XSSFRow row3 = sheet.createRow(3);
        row3.createCell(0).setCellValue("预约到诊数据统计");
        sheet.addMergedRegion(new CellRangeAddress(3,3,0,3));

        XSSFRow row4 = sheet.createRow(4);
        row4.createCell(0).setCellValue("今日预约数");
        row4.createCell(1).setCellValue("22");
        row4.createCell(2).setCellValue("今日到诊数");
        row4.createCell(3).setCellValue("234");

        XSSFRow row5 = sheet.createRow(5);
        row5.createCell(0).setCellValue("本周预约数");
        row5.createCell(1).setCellValue("22");
        row5.createCell(2).setCellValue("本周到诊数");
        row5.createCell(3).setCellValue("235");

        XSSFRow row6 = sheet.createRow(6);
        row6.createCell(0).setCellValue("本月预约数");
        row6.createCell(1).setCellValue("22");
        row6.createCell(2).setCellValue("本月到诊数");
        row6.createCell(3).setCellValue("236");

        XSSFRow row7 = sheet.createRow(7);
        row7.createCell(0).setCellValue("热门套餐");
        sheet.addMergedRegion(new CellRangeAddress(7,7,0,3));

        XSSFRow row8 = sheet.createRow(8);
        row8.createCell(0).setCellValue("套餐名称");
        row8.createCell(1).setCellValue("预约数量");
        row8.createCell(2).setCellValue("占比");
        row8.createCell(3).setCellValue("备注");

        //通过输出流将workbook对象输出到磁盘
        FileOutputStream out = new FileOutputStream("E:\\itcast.xlsx");

        xssfWorkbook.write(out);
        out.flush();//清空缓冲区
        out.close();
        xssfWorkbook.close();
    }
}
